package com.zl.codereview;

import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;

public class MyProjectComponent implements ProjectComponent {

    private final Project project;

    public MyProjectComponent(Project project) {
        this.project = project;
    }

    @Override
    public void initComponent() {
        FileEditorManager editorManager = FileEditorManager.getInstance(project);
        editorManager.addFileEditorManagerListener(new MyFileOpenListener());
    }

    @Override
    public void disposeComponent() {
        FileEditorManager editorManager = FileEditorManager.getInstance(project);
        editorManager.removeFileEditorManagerListener(new MyFileOpenListener());
    }

}
